[IA64] IA64 counter part of the change 12204:e6fdb32b786c of xen-unstable.hg
authorawilliam@xenbuild.aw <awilliam@xenbuild.aw>
Fri, 10 Nov 2006 18:14:32 +0000 (11:14 -0700)
committerawilliam@xenbuild.aw <awilliam@xenbuild.aw>
Fri, 10 Nov 2006 18:14:32 +0000 (11:14 -0700)
Remove xc_ia64_get_pfn_list() from setup_guest() in xc_linux_build.c,
use xc_domain_populate_physmap() and xc_domain_translate_gpfn_list().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
tools/libxc/xc_linux_build.c
xen/arch/ia64/xen/dom0_ops.c
xen/arch/ia64/xen/dom_fw.c
xen/arch/ia64/xen/domain.c

index b16497b1b33c41293663ee0b6491b7b378e34490..fb616ca7069e5b7af39b664bca03fcb703775930 100644 (file)
@@ -496,6 +496,26 @@ static int setup_guest(int xc_handle,
     if ( rc != 0 )
         goto error_out;
 
+    if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL )
+    {
+        PERROR("Could not allocate memory");
+        goto error_out;
+    }
+    for ( i = 0; i < nr_pages; i++ )
+        page_array[i] = i;
+    if ( xc_domain_memory_populate_physmap(xc_handle, dom, nr_pages,
+                                           0, 0, page_array) )
+    {
+        PERROR("Could not allocate memory for PV guest.\n");
+        goto error_out;
+    }
+    if ( xc_domain_translate_gpfn_list(xc_handle, dom, nr_pages,
+                                       page_array, page_array) )
+    {
+        PERROR("Could not translate addresses of PV guest.\n");
+        goto error_out;
+    }
+
     dsi.v_start    = round_pgdown(dsi.v_start);
     vinitrd_start  = round_pgup(dsi.v_end);
     start_info_mpa = (nr_pages - 3) << PAGE_SHIFT;
@@ -511,23 +531,10 @@ static int setup_guest(int xc_handle,
     if ( xc_domctl(xc_handle, &domctl) )
         goto error_out;
 
-    if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL )
-    {
-        PERROR("Could not allocate memory");
-        goto error_out;
-    }
-
     start_page = dsi.v_start >> PAGE_SHIFT;
-    if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array,
-                              start_page, nr_pages) != nr_pages )
-    {
-        PERROR("Could not get the page frame list");
-        goto error_out;
-    }
-
     /* in order to get initrd->len, we need to load initrd image at first */
     if ( load_initrd(xc_handle, dom, initrd,
-                     vinitrd_start - dsi.v_start, page_array) )
+                     vinitrd_start - dsi.v_start, page_array + start_page) )
         goto error_out;
 
     vinitrd_end    = vinitrd_start + initrd->len;
@@ -535,18 +542,9 @@ static int setup_guest(int xc_handle,
     pgnr = (v_end - dsi.v_start) >> PAGE_SHIFT;
     if ( pgnr > nr_pages )
     {
-        free(page_array);
-        if ( (page_array = malloc(pgnr * sizeof(xen_pfn_t))) == NULL )
-        {
-            PERROR("Could not reallocate memory");
-            goto error_out;
-        }
-        if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array,
-                                  start_page, pgnr) != pgnr )
-        {
-                PERROR("Could not get the page frame list");
-                goto error_out;
-        }
+        PERROR("too small memory is specified. "
+               "At least %ld kb is necessary.\n",
+               pgnr << (PAGE_SHIFT - 10));
     }
 
     IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n"
@@ -558,31 +556,21 @@ static int setup_guest(int xc_handle,
            _p(dsi.v_start),     _p(v_end));
     IPRINTF(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
 
-    (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array,
-                           &dsi);
-
-    /* Now need to retrieve machine pfn for system pages:
-     *  start_info/store/console
-     */
-    pgnr = 3;
-    if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array,
-                              nr_pages - 3, pgnr) != pgnr )
-    {
-        PERROR("Could not get page frame for xenstore");
-        goto error_out;
-    }
+    (load_funcs.loadimage)(image, image_size, xc_handle, dom,
+                           page_array + start_page, &dsi);
 
-    *store_mfn = page_array[1];
-    *console_mfn = page_array[2];
+    *store_mfn = page_array[nr_pages - 2];
+    *console_mfn = page_array[nr_pages - 1];
     IPRINTF("start_info: 0x%lx at 0x%lx, "
            "store_mfn: 0x%lx at 0x%lx, "
            "console_mfn: 0x%lx at 0x%lx\n",
-           page_array[0], nr_pages - 3,
+           page_array[nr_pages - 3], nr_pages - 3,
            *store_mfn,    nr_pages - 2,
            *console_mfn,  nr_pages - 1);
 
     start_info = xc_map_foreign_range(
-        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, page_array[0]);
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+        page_array[nr_pages - 3]);
     memset(start_info, 0, sizeof(*start_info));
     rc = xc_version(xc_handle, XENVER_version, NULL);
     sprintf(start_info->magic, "xen-%i.%i-ia64", rc >> 16, rc & (0xFFFF));
index 7bf0500cb8e3637c9f9a407500490a9e7cca4b53..8d53e43ff384d4e0f70ba84265420a12bfe7f29d 100644 (file)
@@ -24,7 +24,6 @@
 #include <xen/errno.h>
 #include <xen/nodemask.h>
 
-void build_physmap_table(struct domain *d);
 #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
 
 extern unsigned long total_pages;
@@ -117,7 +116,6 @@ long arch_do_domctl(xen_domctl_t *op, XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
                 vmx_setup_platform(d);
             }
             else {
-                build_physmap_table(d);
                 dom_fw_setup(d, ds->bp, ds->maxmem);
                 if (ds->xsi_va)
                     d->arch.shared_info_va = ds->xsi_va;
index b2c3f8ef6a24b5fe7b8575f11e9706d1fa68e163..91b618ee88d17376d9e3692877d3d22d0c0e60d0 100644 (file)
@@ -55,9 +55,9 @@ extern unsigned long running_on_sim;
                tables->func_ptrs[pfn++] = 0;                           \
        } while (0)
 
-// allocate a page for fw
-// build_physmap_table() which is called by new_thread()
-// does for domU.
+/* allocate a page for fw
+ * guest_setup() @ libxc/xc_linux_build.c does for domU
+ */
 static inline void
 assign_new_domain_page_if_dom0(struct domain *d, unsigned long mpaddr)
 {
@@ -634,9 +634,10 @@ complete_dom0_memmap(struct domain *d,
        sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
             efi_mdt_cmp, NULL);
 
-       // dom0 doesn't need build_physmap_table()
-       // see arch_set_info_guest()
-       // instead we allocate pages manually.
+       /* setup_guest() @ libxc/xc_linux_build() arranges memory for domU.
+        * however no one arranges memory for dom0,
+        * instead we allocate pages manually.
+        */
        for (i = 0; i < num_mds; i++) {
                md = &tables->efi_memmap[i];
                if (md->phys_addr > maxmem)
index 3b5a2c5ed076d386112a31a0de320a286b29305d..ec0d415a054e5af4cc35e8d5ce76bb5e49cd7cba 100644 (file)
@@ -628,21 +628,6 @@ void domain_relinquish_resources(struct domain *d)
            xfree(d->arch.sal_data);
 }
 
-void build_physmap_table(struct domain *d)
-{
-       struct list_head *list_ent = d->page_list.next;
-       unsigned long mfn, i = 0;
-
-       while(list_ent != &d->page_list) {
-           mfn = page_to_mfn(list_entry(
-               list_ent, struct page_info, list));
-           assign_domain_page(d, i << PAGE_SHIFT, mfn << PAGE_SHIFT);
-
-           i++;
-           list_ent = mfn_to_page(mfn)->list.next;
-       }
-}
-
 unsigned long
 domain_set_shared_info_va (unsigned long va)
 {